package com.campus.service.Impl;

import com.campus.dao.UnintDao;
import com.campus.pojo.ProParamInfo;
import com.campus.pojo.ProUnitInfo;
import com.campus.service.UnitInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
public class UnitInfoServiceImpl implements UnitInfoService {
    @Autowired
    UnintDao dao;

    @Override
    public List<ProUnitInfo> selectByPage(Map<String, Object> params) {
        return dao.selectByPage(params);
    }

    @Override
    public int count(Map<String, Object> params) {
        return dao.count(params);
    }

    @Override
    public List<ProParamInfo> selectAllType(String areaId) {
        return dao.selectAllType(areaId);
    }

    @Override
    public int addUnitInfo(ProUnitInfo info) {
        String id = String.valueOf(UUID.randomUUID());
        info.setId(id);
        return dao.addUnitInfo(info);
    }

    @Override
    public int isRepeat(ProUnitInfo unitInfo) {
        return dao.isRepeat(unitInfo);
    }

    @Override
    public int deleteUnit(Map<String,Object> params) {
        return dao.deleteUnit(params);
    }

    @Override
    public List<ProUnitInfo> getUnitList(String areaId) {
        return dao.getUnitList(areaId);
    }

    @Override
    public List<ProUnitInfo> queryUnitInfoList(String nameOrCode, String unitTypeId, String unitGradeId, String areaId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("nameOrCode", nameOrCode);
        params.put("unitTypeId", unitTypeId);
        params.put("unitGradeId", unitGradeId);
        params.put("areaId", areaId);
        List<ProUnitInfo> list =dao.getInfo(params);
        return list;
    }
}
